#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main()
{

 /*   int a[N];
    int st[N][21];
    int n;

    int gcd(int a, int b)
    {
        return b ? gcd(b, a % b) : a;
    }

    bool check(int l, int r)
    {
        int k = log(r - l + 1) / log(2);

        int d = gcd(st[l][k], st[r - (1 << k) + 1][k]);
        if (d == 1) return true;
        else return false;

    }

    int main()
    {
        scanf("%d", &n);

        int ans = 0;
        int d = 1;
        for (int i = 1; i <= n; i++)
        {
            scanf("%d", &a[i]);
            if (a[i] == 1) ans++;
        }

        if (ans)
        {
            cout << n - ans << endl;
        }
        else
        {
            for (int i = 1; i <= n; i++) st[i][0] = a[i];

            for (int j = 1; j <= 20; j++)
                for (int i = 1; i <= n; i++)
                    if (i + (1 << j) - 1 <= n)
                        st[i][j] = gcd(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);

            int minv = n + 1;
            for (int i = 1; i <= n; i++)
            {
                int l = i, r = n + 1;
                while (l < r)
                {
                    int mid = l + r >> 1;
                    if (check(i, mid)) r = mid;
                    else l = mid + 1;
                }
                if (r == n + 1) continue;
                minv = min(minv, r - i + 1);
            }
            cout << (minv == n + 1 ? -1 : minv + n - 2) << endl;
        }
     */
    cout << 1;
	return 0;
}